#include <GenericTypeDefs.h>
#include <string.h>
#include <ctype.h>

#include "Protocol.h"

static int isCharacterCompatible (ProtocolParameterType type, int character);

int isArgsCompatible(const BYTE* args, ProtocolParameterType type, int length) {
	int i;
	
	for (i = 0; i < length; i++) {
		if (!isCharacterCompatible(type, args[i]))
			return FALSE;
	}

	return TRUE;
}

static int isCharacterCompatible (ProtocolParameterType type, int character) {
	switch(type) {
		case PARAM_BINARY:
			return character == '0' || character == '1';
		case PARAM_DIGIT:
			return isdigit(character);
		case PARAM_ALPHA:
			return isalpha(character);
		case PARAM_ALNUM:
			return isalnum(character);
		default:
			return FALSE;
	}
}
